/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.plechinger.mcremote.server.strategy;

import com.plechinger.mcremote.data.Request;
import com.plechinger.mcremote.data.RequestMethod;
import com.plechinger.mcremote.data.Response;
import com.plechinger.mcremote.data.ResponseStatus;
import com.plechinger.mcremote.server.craft.CraftServer;

/**
 *
 * @author Lukas
 */

@Strategy(method= RequestMethod.STOP)
public class StopStrategy implements ServerStrategy{

    public Response process(Request request) {
        Response response= new Response();
        try {
            CraftServer.getServer().stop();
            response.setStatus(ResponseStatus.OK);
            response.setMessage("Server stopped.");
        } catch (Exception ex) {
            response.setStatus(ResponseStatus.ERROR);
            response.setMessage(ex.getLocalizedMessage());
            response.setResponseObject(ex);
        }
        
        return response;
    }
    
}
